<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>查看订单</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="./css/font.css">
        <link rel="stylesheet" href="./css/xadmin.css">
        <script src="./lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="./js/xadmin.js"></script>
        <script src="./js/jquery.min.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5" lay-filter="example">
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="departmentsName" id="departmentsName"  placeholder="请输入二级科室名" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="illnessName" id="illnessName" placeholder="请输疾病名" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="userName" id="userName" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="doctorName" id="doctorName"  placeholder="请输入医生名" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="button" class="layui-btn layui-icon" id="select"   data-type="reload" value=&#xe615; ></input>
                                </div>
                            </form>
                        </div>

                        <div class="layui-card-body ">
                            <table class="layui-table layui-form layui-hide" id="test" >

                            </table>
                        </div>

                    </div>
                </div>
            </div>
        </div> 
    </body>

    <script type="text/html" id="action">


            <a title="查看" onclick="xadmin.open('查看','hospital-order-view.html?id='+'{{d.id}}',600,800)" href="javascript:;">
                <i class="layui-icon">&#xe63c;</i></a>
            <!--<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
                <i class="layui-icon">&#xe640;</i>
            </a>-->

    </script>
    <script id="sta" type="text/html">
        {{# if(d.status==1){ }}
        未支付
        {{# }else if(d.status==2){ }}
        已支付
        {{# }else if(d.status==3){ }}
        已完成
        {{# }else if(d.status==4){ }}
        已取消
        {{# } }}


    </script>

    <script>
        var token =  localStorage.getItem("token");
        var  head = new Headers();
        head.append('token',token);
        layui.use(['layer', 'form','table'], function(){
            var table = layui.table;
            var form = layui.form;
            var element = layui.element;

            table.render({
                elem: '#test'
                ,url: '/hospital/api/back/order/limit' //数据接口
                ,page: true //开启分页
                ,limit:20
                ,headers: {
                    'token':token
                }
                ,where: {"departmentsName":null,"illnessName":null,"userName":null,"doctorName":null}
                ,done:function () {//渲染完成后的回调

                },parseData:function(res){
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.list //解析数据列表
                    };

                },response:{
                    statusCode:0
                }
                ,cols: [[ //表头
                    //,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计'}
                    ,{field: 'id', title: 'ID', width:'10%', hide:true}
                    ,{field: 'userName', title: '账号'}
                    ,{field: 'orderid', title: '订单号'}
                    ,{field:'patientName',title:'就诊人'}
                    ,{field:'hospitalName',title:'医院'}
                    ,{field:'departmentName',title:'科室'}
                    ,{field:'status',title:'状态',templet:'#sta'}
                    ,{field:'creatTime',title:'创建时间'}
                    ,{field:'patientsTime',title:'预约时间'}
                    ,{field:'patientsPhone',title:'联系电话'}
                    ,{fixed:'right',title:'操作',toolbar:'#action'}
                ]]
                ,id:'testReload'
            });
            var $ = layui.$, active = {
                reload: function(){
                    var departmentsName = $("#departmentsName").val();
                    var illnessName = $("#illnessName").val();
                    var userName = $("#userName").val();
                    var doctorName = $("#doctorName").val();
                    //执行重载
                    table.reload('testReload', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        ,where: {
                            departmentsName: departmentsName,
                            illnessName:illnessName,
                            userName:userName,
                            doctorName:doctorName
                        }
                    }, 'data');
                }
            };
            $('#select').on('click', function(){
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });


            //监听table中的工具栏
            table.on('tool(test)',function(obj) {
                //console.log(obj);
                //console.log(obj.data)
                var data = obj.data;
                console.log(data);
                switch (obj.event) {
                    case 'edit':
                        location.href="user-modify.html?id="+data.euUserId;
                        break;
                    case  'del':
                        layer.confirm("确定要删除该用户吗?"+obj.data.euUserName,function (index) {
                            $.ajax({
                                url:"/ecbuy/sys/user/del.json",
                                type:"post",
                                dataType:"json",
                                headers: {
                                    'token':token
                                },
                                data:{"id":data.euUserId},
                                success:function (msg) {
                                    //console.log("删除数据"+msg);
                                    layer.close(index);
                                    if(msg.code==20000){
                                        obj.del();
                                        layer.msg("删除成功！");
                                    }else {
                                        layer.msg("删除失败");
                                    }
                                }
                            });
                        });
                        break;
                }
            });

        });

    </script>
<script>

</script>


</html>